// src/tests/setup.ts
import { vi } from 'vitest';
import { config } from '@vue/test-utils';

// Mock Element Plus components
vi.mock('element-plus', () => {
  return {
    ElButton: {
      template: '<button><slot /></button>'
    },
    ElCard: {
      template: '<div><slot name="header" /><slot /></div>'
    },
    ElTable: {
      template: '<table><slot /></table>'
    },
    ElTableColumn: {
      template: '<td><slot /></td>'
    },
    ElTag: {
      template: '<span><slot /></span>'
    },
    ElRow: {
      template: '<div><slot /></div>'
    },
    ElCol: {
      template: '<div><slot /></div>'
    },
    ElDrawer: {
      template: '<div><slot /></div>'
    },
    ElDialog: {
      template: '<div><slot /></div>'
    },
    ElForm: {
      template: '<form><slot /></form>'
    },
    ElFormItem: {
      template: '<div><slot /></div>'
    },
    ElInput: {
      template: '<input />'
    },
    ElSelect: {
      template: '<select><slot /></select>'
    },
    ElOption: {
      template: '<option><slot /></option>'
    },
    ElUpload: {
      template: '<div><slot /></div>'
    },
    ElSpace: {
      template: '<div><slot /></div>'
    },
    ElSkeleton: {
      template: '<div><slot /></div>'
    },
    ElBadge: {
      template: '<div><slot /></div>'
    },
    ElStatistic: {
      template: '<div><slot /></div>'
    },
    ElCollapse: {
      template: '<div><slot /></div>'
    },
    ElCollapseItem: {
      template: '<div><slot name="title" /><slot /></div>'
    },
    ElDescriptions: {
      template: '<div><slot /></div>'
    },
    ElDescriptionsItem: {
      template: '<div><slot /></div>'
    },
    ElDivider: {
      template: '<hr />'
    },
    ElIcon: {
      template: '<i><slot /></i>'
    }
  };
});

// Mock lodash
vi.mock('lodash', () => {
  return {
    debounce: (fn: Function) => fn,
    throttle: (fn: Function) => fn
  };
});

// Global mocks
global.ResizeObserver = vi.fn().mockImplementation(() => ({
  observe: vi.fn(),
  unobserve: vi.fn(),
  disconnect: vi.fn(),
}));

// Set up Vue Test Utils config
config.global.stubs = {
  transition: false,
  'transition-group': false,
};